/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.ctu.guiproject.server;

import cz.ctu.guiproject.server.manager.LayoutManagerImpl;
import cz.ctu.guiproject.server.shared.Event;
import java.util.LinkedList;
import java.util.List;

/**
 *
 * @author tomas.buk
 */
public class UIServerXML implements UIServer {

    private final List<EventObserver> observers;
    private Event currentEvent;

    public UIServerXML() {
        observers = new LinkedList<>();
    }

    public void eventOccured(Event event) {
        currentEvent = event;
    }

    @Override
    public void registerObserver(EventObserver o) {
        if (!observers.contains(o)) {
            observers.add(o);
        }
    }

    @Override
    public void removeObserver(EventObserver o) {
        observers.remove(o);
    }

    @Override
    public void notifyObservers() {
        for (EventObserver o : observers) {
            o.update(currentEvent);
        }
    }

    @Override
    public LayoutManagerImpl getLayoutManager() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
}
